package com.ruoyi.web.controller.jypc;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.jypc.domain.Point;
import com.ruoyi.jypc.service.IPointService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 上车地点Controller
 * 
 * @author xymc
 * @date 2022-10-24
 */
@RestController
@RequestMapping("/jypc/point")
public class PointController extends BaseController
{
    @Autowired
    private IPointService pointService;

    /**
     * 查询上车地点列表
     */
    @PreAuthorize("@ss.hasPermi('jypc:point:list')")
    @GetMapping("/list")
    public TableDataInfo list(Point point)
    {
        startPage();
        List<Point> list = pointService.selectPointList(point);
        return getDataTable(list);
    }

    /**
     * 查询上车地点列表
     */
    @PreAuthorize("@ss.hasPermi('jypc:point:list')")
    @GetMapping("/listAll")
    public TableDataInfo listAll()
    {
        List<Point> list = pointService.selectPointListAll();
        return getDataTable(list);
    }
    
    /**
     * 导出上车地点列表
     */
    @PreAuthorize("@ss.hasPermi('jypc:point:export')")
    @Log(title = "上车地点", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Point point)
    {
        List<Point> list = pointService.selectPointList(point);
        ExcelUtil<Point> util = new ExcelUtil<Point>(Point.class);
        util.exportExcel(response, list, "上车地点数据");
    }

    /**
     * 获取上车地点详细信息
     */
    @PreAuthorize("@ss.hasPermi('jypc:point:query')")
    @GetMapping(value = "/{pointid}")
    public AjaxResult getInfo(@PathVariable("pointid") Long pointid)
    {
        return AjaxResult.success(pointService.selectPointByPointid(pointid));
    }

    /**
     * 新增上车地点
     */
    @PreAuthorize("@ss.hasPermi('jypc:point:add')")
    @Log(title = "上车地点", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Point point)
    {
        return toAjax(pointService.insertPoint(point));
    }

    /**
     * 修改上车地点
     */
    @PreAuthorize("@ss.hasPermi('jypc:point:edit')")
    @Log(title = "上车地点", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Point point)
    {
        return toAjax(pointService.updatePoint(point));
    }

    /**
     * 删除上车地点
     */
    @PreAuthorize("@ss.hasPermi('jypc:point:remove')")
    @Log(title = "上车地点", businessType = BusinessType.DELETE)
	@DeleteMapping("/{pointids}")
    public AjaxResult remove(@PathVariable Long[] pointids)
    {
        return toAjax(pointService.deletePointByPointids(pointids));
    }
}
